def sortColumns(matrix): 
    result = []
    m = len(matrix)
    n = len(matrix[0])
    for i in range(m):
        result.append([])
    for j in range(n):
        col = []
        for i in range(m):
            col.append(matrix[i][j])
        col.sort()
        for i in range(m):
            result[i].append(col[i])
    return result

def main():
    mx1 = []
    n = int(input())
    for i in range(n):
        numbers = [ eval(x) for x in input().split() ]
        mx1.append(numbers)
    mx2 = sortColumns(mx1)
    for row in mx2:
        print(" ".join(map(str,row)))
    
if __name__ == "__main__":
    main()
